package com.itheima.work;

/**
 * @auther Macrydy
 * @date 2020/7/7 18:47
 */
public class Test2 {
    public static void main(String[] args) {
        method(new Thread() {
            @Override
            public void run() {
                int sum = getSum(100);
                System.out.println(sum);
            }
        });

        new Thread(new Runnable() {
            @Override
            public void run() {
                int sum = getSum(500);
                System.out.println(sum);
            }
        }).start();
    }

    private static void method(Thread thread) {
        thread.start();
    }

    private static int getSum(int i) {
        if (i == 1) {
            return 1;
        } else {
            return i + getSum(i - 1);
        }
    }
}


